import dayjs from "dayjs";
import { useEffect, useState } from "react";
export function useDateFormat(format = "YYYY年MM月DD-HH时mm分ss秒") {
  const [date, setDate] = useState(dayjs().format(format));

  useEffect(() => {
    const timer = setInterval(() => {
      setDate(dayjs().format(format));
    }, 1000);

    return () => {
      clearTimeout(timer);
    };
  }, []);

  return {
    date,
  };
}
